<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<style>
	label {width: auto;}
	.opr {margin: 3px 2px;}
	.dispose {text-decoration: line-through; color: red;}
	ul.infoshow {padding:5px 0 0 5px; overflow:auto; width: 80%;}
	ul.infoshow li {line-height: 30px; float:left; margin-right: 15px;}
	.opdisabled {text-decoration: line-through; color: #DDD; line-height: 21px;}
	td.ongoing {background-color: #99FF99; color: #333;}
	td.finished {background-color: #ddd;}
	.ps_2 {background-color: #DDD}
	.ps_3 {background-color: #99FF99}
</style>

<script>
	$(function(){
		polish_year_droplist("year_mat", 
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectYear ne null && formEntity.condVO.condProjectYear ne '' ? formEntity.condVO.condProjectYear : 'null'});
		
		polish_month_droplist("month_mat",
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectMonth ne null && formEntity.condVO.condProjectMonth ne '' ? formEntity.condVO.condProjectMonth : 'null'}, false);
		
		$("#month_mat").change(function(){
			if ($("#year_mat").val() == "") {
				alertMsg.error("请先选择年份....");
				$("#combox_month_mat").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
		$("#year_mat").change(function(){
			if ($("#year_mat").val() == "") {
				$("#month_mat").val("");
				$("#combox_month_mat").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
	});
</script>

<form id="pagerForm" method="post" action="app/statistic.do?action=pageByMaterialIndex">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
</form>

<!-- SearchBar -->
<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="app/statistic.do?action=pageByMaterialIndex" method="post" id="searchForm" rel="pagerForm">
		<div class="searchBar">
			<table class="searchContent" id="record_form">
				<tr>
					<td>
						<label>所属年份：</label>
						<select class="combox" id="year_mat" name="condVO.condProjectYear" style="width: 120px">
							<option value="">所有</option>
						</select>
					</td>
					<td>
						<label>所属月份：</label>
						<select class="combox" id="month_mat" name="condVO.condProjectMonth" style="width: 120px">
							<option value="">所有</option>
						</select>
					</td>
					<td>
						<label>项目名称：</label>
						<input type="text" name="projectName" rel="pagerForm" value="${formEntity ne null ? formEntity.projectName : ''}" style="width: 140px"/>
					</td>
					<td>
						<label>项目负责人：</label>
						<input id="projectMgrId" name="mgr.id" value="${formEntity ne null && formEntity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
						<input id="projectMgr" type="text" name="mgr.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectManager ne null ? formEntity.projectManager.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="mgr" style="width: 120px"/>
					</td>
				</tr>
				<tr>
					<td>
						<label>项目进展：</label>
						<select class="combox" name="condVO.condProjectProcess" style="width: 120px">
							<option value="">所有</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-1' ? 'selected' : ''}>项目分配</option>
							<logic:present name="processes">
								<logic:iterate name="processes" id="process">
									<option value="${process.nodeTitle}" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq process.nodeTitle ? 'selected' : ''}>${process.nodeTitle}</option>
								</logic:iterate>
							</logic:present>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td id="proj_status">
						<label>项目状态：</label>
						<select class="combox" name="condVO.condProjectStatus" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '' ? 'selected' : ''}>所有</option>
							<option value="-9" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-9' ? 'selected' : ''}>待分配</option>
							<option value="0" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '0' ? 'selected' : ''}>材料待提交</option>
							<option value="1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '1' ? 'selected' : ''}>审批中</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-1' ? 'selected' : ''}>审批退回</option>
							<option value="-2" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-2' ? 'selected' : ''}>暂停</option>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td>
						<label>项目登记人：</label>
						<input id="projectRecorderId" name="recorder.id" value="${formEntity ne null && formEntity.projectRecorder ne null ? entity.projectRecorder.id : ''}" type="hidden"/>
						<input id="projectRecorder" type="text" name="recorder.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectRecorder ne null ? formEntity.projectRecorder.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="recorder" style="width: 140px"/>
					</td>
				</tr>
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				</ul>
			</div>
		</div>
		<input type="hidden" name="currentindex" id="currentindex" value="${currentindex ne null ? currentindex : 0}" />
	</form>
</div>

<!-- Body -->
<div class="pageContent">
	<table class="table" width="100%" layoutH="135">
		<thead>
			<tr>
				<th align="center">序号</th>
				<th align="center">项目编号</th>
				<th align="center">项目名称</th>
				<th align="center">项目负责人</th>
				<th align="center">项目登记人</th>
				<th align="center">项目推荐时间</th>
				<!--
				<th align="center">行业类别</th>
				<th align="center">项目进展</th>
				<th align="center">项目状态</th>
				<th align="center">项目登记时间</th>
				-->
				<logic:present name="materialTypes">
					<logic:iterate name="materialTypes" id="type">
						<th align="center" class="thover">${type.materialName}</th>
					</logic:iterate>
				</logic:present>
				<th align="center" class="thover">必须材料</th>
			</tr>
		</thead>
		<tbody>
			<logic:present name="datagrid">
				<logic:iterate name="datagrid" property="items" id="entity" indexId="idx">
					<tr ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
						<td>${idx+1}</td>
						<td style="text-align:center">${entity.projectNo}</td>
						<td style="text-align:left">${entity.projectName}</td>
						<td style="text-align:left">
							${entity.projectManager.username}
							<c:if test="${entity.currentProcess eq null && entity.projectStatus eq 1}">(未经部长分配)</c:if>
						</td>
						<td>${entity.projectRecorder ne null ? entity.projectRecorder.username : '---'}</td>
						<td><fmt:formatDate value="${entity.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
						<%--
						<td style="text-align:left">${entity.projectType.dictKey}</td>
						<td>
							<c:choose>
								<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">项目分配</c:when>
								<c:when test="${entity.currentProcess ne null}">${entity.currentProcess.nodeTitle}</c:when>
								<c:when test="${entity.projectStatus eq 2 || entity.projectStatus eq 3 || entity.projectStatus eq -2}">审批结束</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td ${entity.projectStatus eq -2 ? 'style="background-color: #FF9500"' : (entity.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
							<c:choose>
								<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">待分配</c:when>
								<c:when test="${entity.projectStatus eq 0}">材料待提交</c:when>
								<c:when test="${entity.projectStatus eq 1}">审批中</c:when>
								<c:when test="${entity.projectStatus eq -1}">审批退回</c:when>
								<c:when test="${entity.projectStatus eq -2}">已暂停</c:when>
								<c:when test="${entity.projectStatus eq 2 || entity.projectStatus eq 3}">审批结束</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td><fmt:formatDate value="${entity.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
						--%>
						<logic:present name="materialTypes">
							<logic:iterate name="materialTypes" id="type" indexId="pidx">
								<td align="center" class="thover">
									<logic:iterate name="entity" property="materials" length="1" offset="${pidx}" id="material">
										<c:choose>
											<c:when test="${material.totalMaterialCount gt 0}">
												<a title="${entity.projectName} / ${type.materialName} / 材料一览" style="text-decoration: underline;color: blue" href="app/statistic.do?action=dialogMaterialList&pid=${entity.id}&tid=${type.id}" target="dialog" width="900" height="500" rel="prj_stuff_type_${entity.id}_${material.id}">${material.totalMaterialCount}</a>
											</c:when>
											<c:otherwise>${material.totalMaterialCount}</c:otherwise>
										</c:choose>
									</logic:iterate>
								</td>
							</logic:iterate>
						</logic:present>
						<td class="thover">
							<c:choose>
								<c:when test="${entity.mandatoryMaterialInfo.left gt 0}">
									<a style="text-decoration: underline;color: blue" href="app/statistic.do?action=dialogMaterialList&pid=${entity.id}&mandatory" target="dialog" width="1200" height="650" rel="prj_stuff_mand_${entity.id}">${entity.mandatoryMaterialInfo.left} / ${entity.mandatoryMaterialInfo.right}</a>
								</c:when>
								<c:otherwise>${entity.mandatoryMaterialInfo.left} / ${entity.mandatoryMaterialInfo.right}</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
</div>


<!-- Pagination -->
<div class="panelBar">
	<div class="pages">
		<span>显示</span>
		<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
			<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
			<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
			<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
			<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
		</select>
		<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
	</div>
	<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>
</div>